package com.hyl.crmvuedemo;

import com.alibaba.fastjson.JSON;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description TODO
 * @Author hyl
 * @Date 2022/6/29 14:23
 **/
@RestController
@CrossOrigin(originPatterns = {"http://127.0.0.1:8848","http://localhost:8080"})
public class UserController {

	@RequestMapping(value = "/test")
	public String test(HttpServletResponse response){
		//response.addHeader("Access-Control-Allow-Origin", "http://127.0.0.1:8848");

		List<User> list = new ArrayList<User>();
		for(int i=0;i<10;i++){
			User tmp = new User("2022-12-12", "牛马"+i,"郴州");
			list.add(tmp);
		}

		return JSON.toJSONString(list);
//		return "HelloWorld";
	}
}
